<?php

    class LanguageConfig
    {
        private static $sites = array(
            SiteLanguage::RU => "(ru)",
            SiteLanguage::FR => "(fr)"
        );

        private static $cultures = array(
           SiteLanguage::EN => 'en_US',
           SiteLanguage::RU => 'ru_RU',
           SiteLanguage::FR => 'fr_FR'
        );

        /**
         * Returns language of current site.
         *
         * @return string
         */
        public static function GetLang()
        {
            static $lang;
            if ( !isset( $lang ) )
            {
                $host = parse_url( SITE_URL, PHP_URL_HOST );
                $lang = SiteLanguage::EN;
                foreach ( self::$sites as $sitesLang => $pattern )
                {
                    if (preg_match($pattern, $host) > 0)
                    {
                        $lang = $sitesLang;
                        break;
                    }
                }
            }

            return $lang;
        }

        public function GetCulture()
        {
            $lang = self::GetLang();

            return isset(self::$cultures[$lang]) ? self::$cultures[$lang] : SiteLanguage::EN;
        }
    }

?>